﻿using Sdk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sdk.FileReader.Markdown
{
    static public class MdLineTypes
    {
        static public string[] Table { get; } = ["```Table", "```表名"];

        static public string[] Data { get; } = ["```Data", "```数据"];

        static public string[] SQL { get; } = ["```Sql"];

        static public string[] Code { get; } = ["```Code", "```"];


        static public LineTypeEnum GetLineType(this string s)
        {
            var t = LineTypeEnum.Text;
            var ss = s.Trim();
            if (ss.IsMatchType(Table))
            {
                t = LineTypeEnum.TableRow;
            }
            //else if (ss.IsMatchType(Data))
            //{
            //    t = LineTypeEnum.Data;
            //}
            else if (ss.IsMatchType(SQL))
            {
                t = LineTypeEnum.SQL;
            }
            //else if (ss.IsMatchType(Code))
            //{
            //    t = LineTypeEnum.Code;
            //}
            else
            {
                t = LineTypeEnum.Text;
            }
            return t;
        }

        static public bool IsMatchType(this string line, string[] types)
        {
            foreach (var t in types)
            {
                if (line.StartsWith(t, StringComparison.OrdinalIgnoreCase))
                {
                    return true;
                }
            }
            return false;
        }

    }
}
